package com.llbnk.srb.core.controller.api;

import com.llbnk.common.result.R;
import com.llbnk.srb.core.pojo.entity.Dict;
import com.llbnk.srb.core.service.DictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 在借款人登录借款页面的时候 http://localhost:3000/user/borrower
 * 填写个人信息这一栏中都是加载的数据字典里的内容
 * 所以下面方法适用于操作数据字典返回给前端
 * @author shkstart
 * @create 2022-04-17 14:41
 */
@Api(tags = "数据字典")
@RestController
@RequestMapping("/api/core/dict")
@Slf4j
public class DictController {

    @Resource
    private DictService dictService;

    @ApiOperation("根据dictCode获取下级节点")
    @GetMapping("/findByDictCode/{dictCode}")
    public R findByDictCode(
            @ApiParam(value = "节点编码", required = true)
            @PathVariable String dictCode
    ){
        //这个就是根据数据字典中的大类（行业，学历...）返回里面的小类
        List<Dict> list = dictService.findByDictCode(dictCode);
        return R.ok().data("dictList",list);
    }

}
